import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { basCusListData } from '/@/api/bas/cus/basCus';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('客户选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('客户编码'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('客户名称'),
      field: 'name',
      component: 'Input',
    },
    {
      label: t('所属分公司'),
      field: 'exDefine12',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('客户编码'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 90,
    slot: 'firstColumn',
  },
  {
    title: t('客户名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 110,
  },
  {
    title: t('客户简称'),
    dataIndex: 'abbName',
    key: 'a.abb_name',
    sorter: true,
    width: 90,
  },
  {
    title: t('客户分类'),
    dataIndex: 'cusCls.name',
    key: 'cus.name',
    sorter: true,
    width: 90,
  },
  {
    title: t('所属分公司'),
    dataIndex: 'exDefine12',
    key: 'a.ex_define12',
    sorter: true,
    width: 120,
  },
];

const tableProps: BasicTableProps = {
  api: basCusListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    params.ope = '1'; // 显示未退市客户
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
};
